<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@page import="pdf.test.PDFTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
</head>
<body>
<%
    java.io.ByteArrayOutputStream stream = (java.io.ByteArrayOutputStream) new PDFTest("/JSF入门-01.pdf").map.get("pdf");
    if (stream != null) {
        response.setContentType("application/pdf");
        // 设置响应数据大小  
        response.setContentLength(stream == null ? 0 : stream.size());

        // 将pdf数据流写入响应数据流中  
        ServletOutputStream serletOut = response.getOutputStream();
        stream.writeTo(serletOut);
        out.clear();
        out = pageContext.pushBody();
        serletOut.close();
    }
%>
<iframe width="1000px" height="500px" frameborder="1" src="<%=request.getContextPath()%>/pdfView"></iframe>
</body>
</html>